package wrappers;

import entities.Department;
import java.util.*;

/**
 *
 * @author KAV
 */
public class DepartmentWrap extends AbstractWrap {

    private Department e;
    private ViewElement viewCountry;

    public DepartmentWrap(Department _e) {
        e = _e;
    }

    public void setViewCountry(ViewElement _country) {
        viewCountry = _country;
    }

    public ViewElement getViewId() {
        return new ViewElement("id", Integer.toString(e.getDepartment()));
    }

    public ViewElement getViewTitle() {
        return new ViewElement("title", e.getTitle());
    }

    public ViewElement getViewCountry() {
        return viewCountry;
    }

    @Override
    public int compareTo(Object o) {
        int result = 0;
        DepartmentWrap ew = (DepartmentWrap) o;
        switch (compareCase) {
            case 0:
                result = (isAscending) ? (this.e.getDepartment() - ew.e.getDepartment()) : (ew.e.getDepartment() - this.e.getDepartment());
                break;
            case 1:
                result = (isAscending) ? (this.e.getTitle().compareTo(ew.e.getTitle())) : (ew.e.getTitle().compareTo(this.e.getTitle()));
                break;
            case 2:
                result = (isAscending) ? (this.e.getCountry() - ew.e.getCountry()) : (ew.e.getCountry() - this.e.getCountry());
                break;
        }
        return result;
    }

    @Override
    public List<String> getHeaders() {
        List<String> headers = new LinkedList<String>();
        headers.add(getViewId().getHeader());
        headers.add(getViewTitle().getHeader());
        headers.add(getViewCountry().getHeader());
        return headers;
    }

    @Override
    public List<String> getCells() {
        List<String> cells = new LinkedList<String>();
        cells.add(getViewId().toString());
        cells.add(getViewTitle().toString());
        cells.add(getViewCountry().toString());
        return cells;
    }

    @Override
    public String getPrimaryKey() {
        return getViewId().toString();
    }
}
